//
//  ViewController.m
//  ZTY_Cartoon
//
//  Created by 赵佟越 on 15/12/25.
//  Copyright © 2015年 赵佟越. All rights reserved.
//

#import "ViewController.h"
#import <Masonry.h>

#import ""
#import "ZTY_NetHander.h"




@interface ViewController ()
@property(nonatomic, retain)UIButton *btnone;
@property(nonatomic, retain)UIButton *btntow;

// 数据
@property(nonatomic, retain)NSMutableDictionary *BigDic;
@property(nonatomic, retain)NSMutableArray *newarr;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self creatTitle];
    [self creatData];
    
    
    
    // Do any additional setup after loading the view, typically from a nib.
}

- (UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}


// 数据处理 :
- (void)creatData{
    [ZTY_NetHander requestGETWithURL:WEB cookie:nil completion:^(id result) {
        self.BigDic = result[@"data"];
        
//        NSLog(@"%@",self.BigDic);
        [self creatLunBoTu];
        
    }];
}


// 轮播图 :

- (void)creatLunBoTu{
    NSDictionary *dicLunBoTu = self.BigDic[@"banner"];
    
    // scrollView
    UIScrollView *scrollLunBo = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_WIDTH * 8/16)];
    scrollLunBo.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:scrollLunBo];
    
    // scrollView 属性设置
    NSNumber * num = dicLunBoTu[@"count"];
    scrollLunBo.contentSize = CGSizeMake(375 * (num.integerValue + 2) *WIDTH, 0);
    scrollLunBo.pagingEnabled = YES;
    
    
    for (int i = 0; i <= num.integerValue ; i++) {
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(375 *WIDTH *i, 0, SCREEN_WIDTH, SCREEN_WIDTH * 8/16)];
        imageView.tag = 1000 + i;
        imageView.image = [UIImage ]
    }
    
    
}


- (void)creatTitle{
    
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    // navigation 显隐
    self.navigationController.navigationBarHidden =YES;
    // 背景
    UIView *backTitleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    backTitleView.backgroundColor = [UIColor colorWithRed:238/255.0 green:111/255.0 blue:72/255.0 alpha:0.8];
    [self.view addSubview:backTitleView];
    
    //Line
    UIView *lineView = [[UIView alloc]init];
    lineView.backgroundColor = [UIColor whiteColor];
    [backTitleView addSubview:lineView];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(25);
        make.size.mas_equalTo(CGSizeMake(2, 20));
        make.centerX.mas_equalTo(self.view);
    }];
    
    // Btn
    self.btnone = [[UIButton alloc]init];
    [self.btnone setTitle:@"今日推" forState:0];
    [self.btnone setTintColor:[UIColor whiteColor]];
    [backTitleView addSubview:self.btnone];
    [self.btnone addTarget:self action:@selector(changeone) forControlEvents:UIControlEventTouchUpInside];
    
    
    self.btntow = [[UIButton alloc]init];
    [self.btntow setTitle:@"分类找" forState:0];
    [self.btntow setTintColor:[UIColor whiteColor]];
    [backTitleView addSubview:self.btntow];
    [self.btntow addTarget:self action:@selector(changetow) forControlEvents:UIControlEventTouchUpInside];
    
    [self.btnone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 50));
        make.top.offset(10);
        make.centerX.mas_equalTo(self.view).offset(-40);
    }];
    
    [self.btntow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 50));
        make.top.offset(10);
        make.centerX.mas_equalTo(self.view).offset(40);
    }];
}

///////





// Title 点击方法
- (void)changeone{
    [self.btnone setTitle:@"今日推" forState:UIControlStateHighlighted];
    
}

- (void)changetow{
    [self.btntow setTitle:@"分类找" forState:UIControlStateHighlighted];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
